<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<html>
<%
Sub ShowChart(ByRef aValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)

	Const GRAPH_WIDTH  = 450  // The width of the body of the graph
	Const GRAPH_HEIGHT = 250  // The heigth of the body of the graph
	Const GRAPH_BORDER = 5    // The size of the black border
	Const GRAPH_SPACER = 2    // The size of the space between the bars

	
	Const TABLE_BORDER = 0

    // Declare our variables
	Dim I
	Dim iMaxValue
	Dim iBarWidth
	Dim iBarHeight

	//Recibe el valor maximo en set de datos
	iMaxValue = 0
	For I = 0 To UBound(aValues)
		If iMaxValue < aValues(I) Then iMaxValue = aValues(I)
	Next //I
	//Response.Write iMaxValue // Debugging line

    //Calcula el ancho de la cuadro	

	iBarWidth = (GRAPH_WIDTH \ (UBound(aValues) + 1)) - GRAPH_SPACER
	 //Response.Write iBarWidth 


    // Comenzando a dibujar el cuadro
	%>
	<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
		<TR>
			<TD COLSPAN="3" ALIGN="center"><H2><%= strTitle %></H2></TD>
		</TR>
		<TR>
			<TD VALIGN="center"><B><%= strYAxisLabel %></B></TD>
			<TD VALIGN="top">
				<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
					<TR>
						<TD ROWSPAN="2"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="1" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
						<TD VALIGN="top" ALIGN="right"><%= iMaxValue %>&nbsp;</TD>
					</TR>
					<TR>
						<TD VALIGN="bottom" ALIGN="right">0&nbsp;</TD>
					</TR>
				</TABLE>
			</TD>
			<TD>
				<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
					<TR>
						<TD VALIGN="bottom"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER %>" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
					<%
					//Ahora formamos el cuerpo del cuadro.  El ciclo muestra los graficos del sistema!
					For I = 0 To UBound(aValues)
						iBarHeight = Int((aValues(I) / iMaxValue) * GRAPH_HEIGHT)

						// This is a hack since browsers ignore a 0 as an image dimension!
						If iBarHeight = 0 Then iBarHeight = 1
					%>
						<TD VALIGN="bottom"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="<%= GRAPH_SPACER %>" HEIGHT="1"></TD>
						<TD VALIGN="bottom"><IMG SRC="./images/spacer_red.gif" BORDER="0" WIDTH="<%= iBarWidth %>" HEIGHT="<%= iBarHeight %>" ALT="<%= aValues(I) %>"></TD>
					<%
					Next //I
					%>
					</TR>

					<!-- I was using GRAPH_BORDER + GRAPH_WIDTH but it was moving the last x axis label -->
					<TR>
						<TD COLSPAN="<%= (2 * (UBound(aValues) + 1)) + 1 %>"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER + ((UBound(aValues) + 1) * (iBarWidth + GRAPH_SPACER)) %>" HEIGHT="<%= GRAPH_BORDER %>"></TD>
					</TR>
				<% //The label array is optional and is really only useful for small data sets with very short labels! %>
				<% If IsArray(aLabels) Then %>
					<TR>
						<TD><!-- Dando espcio a los bordes de la columna --></TD>
					<% For I = 0 To UBound(aValues)  %>
						<TD><!-- Spacing for Spacer Column --></TD>
						<TD ALIGN="center"><FONT SIZE="1"><%= aLabels(I) %></FONT></TD>
					<% Next //I %>
					</TR>
				<% End If %>
				</TABLE>
			</TD>
		</TR>
		<TR>
			<TD COLSPAN="2"><!-- Place holder for X Axis label centering--></TD>
			<TD ALIGN="center"><BR><B><%= strXAxisLabel %></B></TD>
		</TR>
	</TABLE>
	<%
End Sub
%>

<head>
<title>CHART O CUADRO</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

</body>
</html>
